package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.DepositHistory;
import com.pgybook.db.entity.domain.DepositHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface DepositHistoryMapper {
    int countByExample(DepositHistoryEx example);

    int deleteByExample(DepositHistoryEx example);

    @Delete({
            "delete from deposithistory",
            "where DEPOSITHISID = #{deposithisid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long deposithisid);

    @Insert({
            "insert into deposithistory (CUSTID, PAYCOMPANYID, ",
            "AMOUNT, CRTTIME, ",
            "ORIGDAYS, DESTDAYS)",
            "values (#{custid,jdbcType=BIGINT}, #{paycompanyid,jdbcType=INTEGER}, ",
            "#{amount,jdbcType=DECIMAL}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{origdays,jdbcType=INTEGER}, #{destdays,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "deposithisid", before = false, resultType = Long.class)
    int insert(DepositHistory record);

    int insertSelective(DepositHistory record);

    List<DepositHistory> selectByExample(DepositHistoryEx example);

    @Select({
            "select",
            "DEPOSITHISID, CUSTID, PAYCOMPANYID, AMOUNT, CRTTIME, ORIGDAYS, DESTDAYS",
            "from deposithistory",
            "where DEPOSITHISID = #{deposithisid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    DepositHistory selectByPrimaryKey(Long deposithisid);

    int updateByExampleSelective(@Param("record") DepositHistory record, @Param("example") DepositHistoryEx example);

    int updateByExample(@Param("record") DepositHistory record, @Param("example") DepositHistoryEx example);

    int updateByPrimaryKeySelective(DepositHistory record);

    @Update({
            "update deposithistory",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "ORIGDAYS = #{origdays,jdbcType=INTEGER},",
            "DESTDAYS = #{destdays,jdbcType=INTEGER}",
            "where DEPOSITHISID = #{deposithisid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(DepositHistory record);
}
